// 添加过渡动画
function addTransitionAnimations() {
    // 为所有概率条添加动画
    const probabilityItems = document.querySelectorAll('.probability-item');
    probabilityItems.forEach((item, index) => {
        item.style.animation = `fadeIn 0.5s ease ${index * 0.1}s forwards`;
        item.style.opacity = '0';
    });
    
    // 为上传区域添加动画
    const uploadArea = document.querySelector('.upload-area');
    if (uploadArea) {
        uploadArea.style.animation = 'fadeIn 0.5s ease forwards';
    }
    
    // 为可视化容器添加动画
    const visualizationContainer = document.querySelector('.visualization-container');
    if (visualizationContainer) {
        visualizationContainer.style.animation = 'fadeIn 0.5s ease 0.2s forwards';
        visualizationContainer.style.opacity = '0';
    }
}

// 显示Toast提示
function showToast(message, type = 'info') {
    // 移除现有的toast
    const existingToast = document.querySelector('.toast-message');
    if (existingToast) {
        existingToast.remove();
    }
    
    // 创建新的toast元素
    const toast = document.createElement('div');
    toast.className = `toast-message toast-${type}`;
    
    // 根据类型设置图标
    let icon = '💬';
    if (type === 'success') icon = '✅';
    if (type === 'error') icon = '❌';
    if (type === 'warning') icon = '⚠️';
    
    toast.innerHTML = `<span class="toast-icon">${icon}</span>${message}`;
    
    // 添加到body
    document.body.appendChild(toast);
    
    // 2.5秒后自动移除
    setTimeout(() => {
        if (toast.parentNode) {
            toast.classList.add('toast-hiding');
            setTimeout(() => {
                if (toast.parentNode) {
                    toast.parentNode.removeChild(toast);
                }
            }, 300);
        }
    }, 2500);
}

// 设置示例图片功能
function setupExampleImages() {
    const exampleImageBtn = document.getElementById('exampleImageBtn');
    const exampleDrawer = document.getElementById('exampleDrawer');
    const closeDrawerBtn = document.getElementById('closeDrawerBtn');
    
    if (exampleImageBtn) {
        exampleImageBtn.addEventListener('click', () => {
            // 打开抽屉
            exampleDrawer.classList.add('open');
        });
    }
    
    // 关闭抽屉按钮
    if (closeDrawerBtn) {
        closeDrawerBtn.addEventListener('click', () => {
            exampleDrawer.classList.remove('open');
        });
    }
}

export { addTransitionAnimations, showToast, setupExampleImages };